package test.enba.swagger.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.ArrayList;
import java.util.List;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Api(tags = "示例接口")
@RestController
@RequestMapping("/api")
public class ExampleController {

  @ApiOperation("获取用户信息")
  @GetMapping("/user/{id}")
  public ResponseResult<User> getUser(
      @ApiParam(value = "用户ID", example = "1") @PathVariable Long id) {
    return null;
  }

  @ApiOperation("创建用户")
  @PostMapping("/user")
  public ResponseResult<User> createUser(@RequestBody User user) {
    // 模拟创建用户
    return null;
  }

  @ApiOperation("分页查询用户")
  @GetMapping("/users")
  public ResponseResult<List<User>> getUsers(
      @ApiParam(value = "页码", example = "1") @RequestParam int page,
      @ApiParam(value = "每页大小", example = "10") @RequestParam int size) {
    List<User> users = new ArrayList<>();
    // 模拟分页查询
    return null;
  }

  @ApiOperation("文件上传")
  @PostMapping("/upload")
  public ResponseResult<String> uploadFile(
      @ApiParam(value = "文件", required = true) @RequestParam("file") MultipartFile file) {
    // 模拟文件上传
    return null;
  }

  @ApiOperation("枚举类型测试")
  @GetMapping("/user/status")
  public ResponseResult<UserStatus> getUserStatus() {
    // 返回枚举类型
    return null;
  }
}
